package com.sell.service.impl;

import com.sell.dataobject.SellerInfo;
import com.sell.enums.ResultEnum;
import com.sell.exception.SellException;
import com.sell.repository.SellerInfoRepository;
import com.sell.service.SellerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author: Xukai
 * @description:
 * @createDate: 2018/7/9 14:06
 * @modified By:
 */
@Service
public class SellerServiceImpl implements SellerService {

    @Autowired
    private SellerInfoRepository sellerInfoRepository;

    @Override
    public SellerInfo findSellerInfoByOpenid(String openid) {
        SellerInfo sellerInfo = sellerInfoRepository.findByOpenid(openid);
        if (sellerInfo == null) {
            throw new SellException(ResultEnum.SELLER_NOT_EXIST);
        }
        return sellerInfo;
    }
}
